/*
 * @Author: 秦福凯
 * @LastEditTime: 2025-01-02 18:00:18
 * @Description: 
 */
import useDictStore from '@/store/dict'

/**
 * 获取字典数据
 */
export function useDict(...args) {
  const res = ref({});
  return (() => {
    args.forEach((dictType, index) => {
      res.value[dictType] = [];
      const dicts = useDictStore().getDict(dictType);
      if (dicts) {
        res.value[dictType] = dicts;
      } else {
        let parmas = {
          timeStamp:'',
          body:'',
          param:args.join(',')
        }
        return
        mainApi.getDictsByType(parmas).then(resp => {
          res.value[dictType] = resp.data.data.childrenList.map(p => ({ label: p.content, value: p.dictValue,id:p.id}))
          useDictStore().setDict(dictType, res.value[dictType]);
        })
      }
    })
    return toRefs(res.value);
  })()
}
